<template>
  <div>
      <h3>{{$store.state.m_user.username}}</h3>
      <van-button @click="loginout">退出登录</van-button>
  </div>
</template>

<script>
export default {
  // 组件名称
  name: "demo",
  beforeRouteEnter(to, from, next) {
    next((vm) => {
      if (vm.$store.state.m_token == "") {
        vm.$router.push("/login");
      }
    });
  }, // 组件参数 接收来自父组件的数据
  props: [], // 局部注册的组件
  components: {}, // 组件状态值
  data() {
    return {};
  }, // 计算属性

  computed: {}, // 侦听器
  watch: {}, // 组件方法
  methods: {
      loginout(){
          this.$store.commit("loginout")
          this.$toast.success("退出成功")
          this.$router.push("/login") 
      }
  }, // 以下是生命周期钩子 注：没用到的钩子请自行删除
  created() {},
  mounted() {},
  updated() {},
};
</script>

<style scoped></style>
